import React from "react"
import { render } from "react-dom"
class Child extends React.Component{
    state={
        msg:"此路是我开，此树是我栽，要想此路过，留下买路财"
    }
    render(){
        return (
            <h1>{this.state.msg}</h1>
        )
    }
}
class Ref extends React.Component {
    ref=React.createRef()
    ref2=React.createRef()
    change=()=>{
        console.log(this.ref)
        this.ref.current.focus()
        console.log(this.ref.current.value)
        console.log(this.ref2)
        this.ref2.current.state.msg="程咬金"
        this.setState({})
    }
    render() {
        return (
            <fieldset>
                <legend>非受控组件</legend>
                <input type="text" ref={this.ref}/>
                <button onClick={this.change}>点击</button>
                <Child ref={this.ref2}/>
            </fieldset>
        )
    }


}
export default Ref